from types import FunctionType


class Foo:
    
    param = "BLA"
    
    def testing(self, name):
        print "Name: %s" % name
    
    def asdf(self):
        pass
    
    

#f = Foo()    
    
def trace( method ):
    """ Add trace information to the specified method """
    
    def trace_decorator( *args, **kwargs ):
        """ Trace Decorator """
        
        print "! ----------------------------------------------------------------"
        print "Calling: %s( %s | %s )" % (str(method.func_name), args, kwargs)
        rv = method( *args, **kwargs )
        print "%s returned: %s" % ( str(method.func_name), rv)
        print "| ================================================================"
        return rv

    return trace_decorator

def applyTrace( cls ):
    #return # Disable
    for key, value in cls.__dict__.items():
        if type(value) is FunctionType:
            print "Adding trace to %s" % `key`
            setattr(cls, key, trace(value))
        
        
        
#applyTrace( Foo )        



#f.testing("John")
